<Project>
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <!-- Requires explicit Main as it implements command-line parameters for local testing purposes. -->
    <RequiresProcessIsolation>true</RequiresProcessIsolation>
    <ReferenceXUnitWrapperGenerator>false</ReferenceXUnitWrapperGenerator>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="BinderTracingTest.cs" />
    <Compile Include="BinderEventListener.cs" />
    <Compile Include="Helpers.cs" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
    <ProjectReference Include="AssemblyToLoad.csproj" />
  </ItemGroup>
  <ItemGroup>
    <!-- Build the same AssemblyToLoad project with a different assembly name. These will be moved to a subdirectory
         by the MoveDependentAssembliesToSubdirectory target, such that they will not be on the test's app path -->
    <ProjectReference Include="AssemblyToLoad.csproj">
      <Properties>AssemblyNameSuffix=Subdirectory</Properties>
      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
      <OutputItemType>Content</OutputItemType>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
      <Targets>Build;SatelliteDllsProjectOutputGroup</Targets>
    </ProjectReference>
    <ProjectReference Include="AssemblyToLoad.csproj">
      <Properties>AssemblyNameSuffix=SubdirectoryMismatch</Properties>
      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
      <OutputItemType>Content</OutputItemType>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </ProjectReference>
    <ProjectReference Include="AssemblyToLoad.csproj" Link="AssemblyToLoad_V2.dll">
      <Properties>AssemblyV2=true</Properties>
      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
      <OutputItemType>Content</OutputItemType>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </ProjectReference>
  </ItemGroup>

  <Target Name="MoveDependentAssembliesToSubdirectory" AfterTargets="CopyFilesToOutputDirectory">
    <PropertyGroup>
      <AssemblyToLoadResourceCulture>fr-FR</AssemblyToLoadResourceCulture>
      <DependentAssembliesDirectory>$(OutDir)/DependentAssemblies</DependentAssembliesDirectory>
    </PropertyGroup>
    <ItemGroup>
      <SatelliteAssembliesToMove Include="$(OutDir)/**/AssemblyToLoad_*.resources.*" Exclude="$(DependentAssembliesDirectory)/**" />
      <AssembliesToCopy Include="$(OutDir)/AssemblyToLoad.dll" />
      <AssembliesToMove Include="$(OutDir)/AssemblyToLoad_*.*" />
      <AssembliesToMove Include="$(OutDir)/AssemblyToLoadDependency.*" />
    </ItemGroup>
    <Copy SourceFiles="@(AssembliesToCopy)" DestinationFolder="$(DependentAssembliesDirectory)" />
    <Move SourceFiles="@(AssembliesToMove)" DestinationFolder="$(DependentAssembliesDirectory)" />
    <Move SourceFiles="@(SatelliteAssembliesToMove)" DestinationFolder="$(DependentAssembliesDirectory)/$(AssemblyToLoadResourceCulture)" />
  </Target>
</Project>
